const {ipcRenderer} = require('electron');
const $ = require('./resources/jquery3-7-0.mini')

//获取鼠标按下时的x位置
let getWindowBeforePageX;
//获取鼠标松开时的x位置
let getWindowafterPageX;
//获取鼠标按下时的y位置
let getWindowBeforePageY;
//获取鼠标松开时的y位置
let getWindowafterPageY;

let i = 0
const change = async() => {
    const pinnedImage = document.getElementById("pinnedImage");
    console.log(pinnedImage.src,i)
    if(i == 0){
        pinnedImage.style.transform = 'rotate3d(0,0,1,-45deg)';
        ipcRenderer.send('learn-top')
        i = 1;
    }else{
        // pinnedImage.src = "images/Pinned_xie.svg"
        pinnedImage.style.transform = 'rotate3d(0,0,1,0deg)';
        ipcRenderer.send('learn-no-top')
        i = 0;
    }
}

const clickClose = async() => {
    ipcRenderer.send('learn-close');
}

window.addEventListener('mousedown',(event)=>{
    if(event.pageX || event.pageY){
        getWindowBeforePageX = event.pageX
        getWindowBeforePageY = event.pageY
        console.log({x:event.pageX,y:event.pageY})
    }
})
//鼠标松开时触发
window.addEventListener('mouseup',(event)=>{
    if(event.pageX || event.pageY){
        getWindowafterPageX = event.pageX
        getWindowafterPageY = event.pageY
        console.log({x:event.pageX,y:event.pageY})
    }
    if(getWindowBeforePageX -  getWindowafterPageX > 0){
        //左拉
        console.log('左拉')
        ipcRenderer.send('show-newWin-left')
    }
})

//jquery
$('#go-image').click(()=>{
    // window.location.href = './learn/golang.html'
    ipcRenderer.send('learn-go-page')
    ipcRenderer.send('show-learn-go')
})
$('#vue-image').click(()=>{
    // window.location.href = './learn/golang.html'
    ipcRenderer.send('learn-vue-page')
    ipcRenderer.send('show-learn-vue')
})
$('#react-image').click(()=>{
    // window.location.href = './learn/golang.html'
    ipcRenderer.send('learn-react-page')
    ipcRenderer.send('show-learn-react')
})
$('#python-image').click(()=>{
    // window.location.href = './learn/golang.html'
    ipcRenderer.send('learn-python-page')
    ipcRenderer.send('show-learn-python')
})